Skip to content

Conversation

@cd-bitwarden
Copy link
Contributor

@cd-bitwarden cd-bitwarden commented Oct 22, 2025

🎟️ Tracking

https://bitwarden.atlassian.net/browse/SM-1740
https://bitwarden.atlassian.net/browse/SM-1742

📔 Objective

Adding the new column to the database for adding a new item to the organization table for "disabling SM ads for users", this new item is called UseDisableSMAdsForUsers.

📸 Screenshots

N/A

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@github-actions
Copy link
Contributor

github-actions bot commented Oct 22, 2025

Logo
Checkmarx One – Scan Summary & Details31a69e11-bac3-4df6-bcf4-ca4401692fe5

Fixed Issues (3)

Great job! The following issues were fixed in this Pull Request

Severity Issue Source File / Package
MEDIUM CSRF /src/Api/KeyManagement/Controllers/AccountsKeyManagementController.cs: 97
MEDIUM CSRF /bitwarden_license/src/Scim/Controllers/v2/GroupsController.cs: 87
MEDIUM CSRF /bitwarden_license/src/Scim/Controllers/v2/GroupsController.cs: 97

@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

❌ Patch coverage is 70.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.23%. Comparing base (d619a49) to head (126ca9f).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...illing/Organizations/Models/OrganizationLicense.cs 40.00% 3 Missing ⚠️
...Admin/AdminConsole/Models/OrganizationEditModel.cs 33.33% 2 Missing ⚠️
...mplementations/OrganizationLicenseClaimsFactory.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6482      +/-   ##
==========================================
+ Coverage   53.39%   57.23%   +3.83%     
==========================================
  Files        1917     1917              
  Lines       85507    85526      +19     
  Branches     7676     7676              
==========================================
+ Hits        45660    48947    +3287     
+ Misses      38077    34735    -3342     
- Partials     1770     1844      +74     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cd-bitwarden cd-bitwarden marked this pull request as ready for review October 23, 2025 14:00
@cd-bitwarden cd-bitwarden requested review from a team as code owners October 23, 2025 14:00
cyprain-okeke
cyprain-okeke previously approved these changes Oct 27, 2025
Copy link
Contributor

@cyprain-okeke cyprain-okeke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

BTreston
BTreston previously approved these changes Oct 27, 2025
@claude
Copy link
Contributor

claude bot commented Oct 28, 2025

Claude finished @cd-bitwarden's task —— View job


Code Review Complete ✅

I've completed a comprehensive review of this PR. Overall, the implementation is well-structured and consistent with Bitwarden's coding standards. The changes properly add the UseDisableSmAdsForUsers feature to the Organization entity across all database providers and application layers.


Summary

This PR adds a new boolean field UseDisableSmAdsForUsers to the Organization table to control whether Secrets Manager ads should be disabled for users. The implementation follows established patterns and includes proper migrations, tests, and claims-based licensing support.

Key Changes:

  • Database schema updates across SQL Server, MySQL, PostgreSQL, and SQLite
  • Entity model updates and API response models
  • License claims generation and validation
  • Admin UI form updates
  • Comprehensive test coverage

Findings

Strengths

  1. Consistent naming: The field uses UseDisableSmAdsForUsers with Pascal case "Sm" (capital S, lowercase m), matching existing Secrets Manager fields like SmSeats, SmServiceAccounts, etc.

  2. Comprehensive database coverage: All four database providers (SQL Server, MySQL, PostgreSQL, SQLite) have proper migrations with correct default values.

  3. Proper view refresh: The SQL Server migration script correctly refreshes all views that reference the Organization table (lines 13-17 in migration script).

  4. Claims-based licensing: The new field is properly integrated into the modern JWT claims-based licensing system rather than the deprecated property-based system (see OrganizationLicenseClaimsFactory.cs:60 and OrganizationLicense.cs:430,468).

  5. Test coverage: Good test coverage including:

    • Claims generation and validation tests (OrganizationLicenseTests.cs:269-293)
    • Entity tests (OrganizationTests.cs)
    • The field is correctly excluded from hash/signature calculations in the frozen license version (lines 234 in OrganizationLicense.cs)
  6. Security: No security vulnerabilities introduced. The field is properly parameterized in all SQL stored procedures, preventing SQL injection.


📝 Minor Observations

  1. Nullable reference types: Several files still have #nullable disable at the top:

    • src/Core/Billing/Organizations/Models/OrganizationLicense.cs:2
    • src/Core/Billing/Licenses/Services/Implementations/OrganizationLicenseClaimsFactory.cs:2
    • src/Api/AdminConsole/Models/Response/Organizations/OrganizationResponseModel.cs:2
    • src/Admin/AdminConsole/Controllers/OrganizationsController.cs:2

    However, this is existing technical debt (noted with FIXME comments) and not introduced by this PR.

  2. Large migration files: The Entity Framework Designer files are very large (3,400+ lines each), but this is normal for EF migrations and includes the entire database snapshot.

  3. Documentation: The Organization.cs entity has good XML documentation for the new property (lines 137-140):

    /// <summary>
    /// If set to true, disables Secrets Manager ads for users in the organization
    /// </summary>
    public bool UseDisableSmAdsForUsers { get; set; }

Database Implementation

SQL Server Migration (util/Migrator/DbScripts/2025-11-26_00_AddDisableSMAdsForUsersToOrganization.sql):

  • ✅ Proper column existence check before adding
  • ✅ Correct data type: BIT NOT NULL
  • ✅ Appropriate default constraint: DEFAULT 0
  • ✅ All views refreshed (5 views)
  • Organization_Create stored procedure updated with new parameter
  • Organization_Update stored procedure updated
  • Organization_ReadAbilities procedure includes new field
  • ✅ Parameter ordering is consistent

Entity Framework Migrations:

  • ✅ MySQL: tinyint(1) with defaultValue: false
  • ✅ PostgreSQL: boolean with defaultValue: false
  • ✅ SQLite: boolean with defaultValue: false
  • ✅ All migrations have proper Up() and Down() methods

Code Quality

  1. Follows ADRs: The implementation respects Bitwarden's Architectural Decision Records, particularly:

    • Uses .NET nullable reference types where applicable (ADR 0024)
    • Follows dependency injection patterns (ADR 0026)
  2. No over-engineering: The changes are minimal and focused. No unnecessary abstractions or premature optimizations.

  3. Consistent patterns: The new field is added in the exact same way as other similar fields (e.g., UsePhishingBlocker, UseAutomaticUserConfirmation).

  4. License versioning: Correctly uses the JWT Token property for the new claim rather than incrementing the frozen license version (version 15). This follows the guidance in the code comments.


💭 Questions/Considerations

  1. Feature flag: Should this feature be protected by a feature flag for gradual rollout? The PR description mentions "Protected functional changes with optionality (feature flags)" in the reminders, but I don't see a feature flag in the code. This may be intentional if it's controlled by the license itself.

  2. Migration date: The migration script is dated 2025-11-26 which is in the future (today is 2025-12-04). This might cause issues if older migrations need to be created. However, this could be intentional if the release is planned for that timeframe.

  3. Documentation: Consider updating any relevant Confluence documentation about organization features and license capabilities as mentioned in the PR reminders.


Conclusion

This is a well-implemented feature that follows Bitwarden's patterns and standards. The code is clean, properly tested, and includes comprehensive database support across all platforms.

Recommendation: ✅ Approve (pending resolution of any feature flag or documentation questions if needed)

The previous review approvals from @cyprain-okeke and @BTreston are appropriate. The PR is ready to merge once any final discussions about feature flags or deployment timing are resolved.


Copy link
Contributor

@mkincaid-bw mkincaid-bw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional refresh statements needed, plus a question regarding casing.

@cd-bitwarden cd-bitwarden dismissed stale reviews from BTreston and cyprain-okeke via 363fa4f November 6, 2025 02:51
BTreston
BTreston previously approved these changes Nov 6, 2025
cyprain-okeke
cyprain-okeke previously approved these changes Nov 6, 2025
Copy link
Contributor

@cyprain-okeke cyprain-okeke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

cyprain-okeke
cyprain-okeke previously approved these changes Nov 28, 2025
Copy link
Contributor

@cyprain-okeke cyprain-okeke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good for Billing But you have some conflict

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants